package com.rlyy.rsj.service.remind;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.rlyy.aibase.utils.base.MapNode;
import com.rlyy.aibase.utils.base.TableNode;
import com.rlyy.aibase.utils.helpers.JsonHelper;
import com.rlyy.rsj.dao.OrgpDao2;
import com.rlyy.rsj.dao.RemindDao;
import com.rlyy.rsj.entity.RemindEntity;
import com.rlyy.rsj.entity.RemindTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author : shibixiao
 * @description :
 * @date : 2021-07-21 10:46
 **/
@Component
public class RemindServiceImpl implements IRemindService{

    @Autowired
    private OrgpDao2 orgpDao2;

    @Autowired
    private RemindDao remindDao;

    @Override
    public List<RemindEntity> getAllOrgpInfo() {
        TableNode orgpRemindInfo = orgpDao2.getOrgpRemindInfo();
        List<RemindEntity> remindEntityList = JSONArray.parseArray(orgpRemindInfo.toJson(), RemindEntity.class);
        return remindEntityList;
    }

    @Override
    public RemindTable getRemindConfigByType(String remindType) {
        MapNode remindInfo = remindDao.getRemindInfoByType(remindType);
        if(remindInfo.size()<=0){
            return null;
        }
        return JSONObject.parseObject(JsonHelper.mapNode2Json(remindInfo), RemindTable.class);
    }
}
